<?php
namespace app\admin\controller;

use app\common\model\Admin;
use app\common\model\GlobalData;
use app\common\model\System as SystemModel;
use think\Request;
use think\Session;

class System extends Base
{
	protected $page_tag='sys';
	protected $page_desc='管理网站基础设置';
	protected $page_title='系统设置';
	
	protected $sub_menu=[
		'index'=>[
			'title'=>'管理员管理',
			'url'=>"/admin/System/index"
		],
		'setting'=>[
			'title'=>'系统设置管理',
			'url'=>"/admin/System/setting"
		]
	];
	public function index()
    {
	    $data['modify_url']=url("/admin/system/modifyAdmin");
	    $vb=new Admin();
	    $condition=[];
	    $data['username']=input('username');
	    $data['status']=input('status');
	    $data['username'] && $condition['username']=['like',"%".$data['username']."%"];
	    $data['status'] !==''  && input('status')!==null && $condition['status']=$data['status'];
	    $data['list']=$vb->getList($condition);
    	return $this->fetch('',$data);
    }
    
    public function modifyAdmin(){
		$this->layout='layout_empty';
	    $data['submit_url']=url("/api/system/modifyAdmin");
	    $data['status_list']=Admin::$status;
	    if(input('id')){
	    	$vb=new Admin();
	    	$data['info']=$vb->getInfo(['id'=>input('id')]);
	    }
	    return $this->fetch('',$data);
    }
    
    public function setting(){
	    $data['submit_url']=url("/api/system/modifySetting");
	    $data_model=new GlobalData();
	    $data['info']=$data_model->getList(['group'=>'system']);
    	return $this->fetch('',$data);
    }
	
}
